import App from './App'
import store from './store'

// #ifndef VUE3
import Vue from 'vue'

import uView from "uview-ui";
Vue.use(uView);

import {
	getTopHeight,
	showToast,
	uploadFile,
	getImgUrl
} from '@/utils/commen.js';
Vue.prototype.$getTopHeight = getTopHeight
Vue.prototype.$showToast = showToast;
Vue.prototype.$uploadFile = uploadFile;
Vue.prototype.$getImgUrl = getImgUrl;

// 添加全局filter
import filters from '@/utils/filter.js'
Object.keys(filters).map(v => {
	Vue.filter(v, filters[v])
})

// import Vconsole from 'vconsole'
// let vConsole = new Vconsole()
// Vue.use(vConsole)

Vue.config.productionTip = false

Vue.prototype.$store = store;

Vue.prototype.getBarHeight = function() {
	return new Promise((resolve, reject) => {
		var that = this
		var isTemp = {}
		uni.getSystemInfo({
			success(res) {
				let totalTopHeight = 68
				if (res.model.indexOf('iPhone X') !== -1) {
					totalTopHeight = 88
				} else if (res.model.indexOf('iPhone') !== -1) {
					totalTopHeight = 64
				}
				isTemp['statusBarHeight'] = res.statusBarHeight
				isTemp['titleBarHeight'] = totalTopHeight - res.statusBarHeight
				isTemp['allHeight'] = totalTopHeight
				resolve(isTemp)
			},
			fail(e) {
				reject(e)
			}
		})
	})
}

App.mpType = 'app'
const app = new Vue({
    ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app,
  }
}
// #endif